package com.qianfeng.smartdevice.controller;

import com.qianfeng.smartdevice.dto.R;
import com.qianfeng.smartdevice.pojo.SysDevice;
import com.qianfeng.smartdevice.service.SysDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @time: 2022-03-22 20:02
 */

@RestController
@RequestMapping("/devices")
public class SysDeviceController {
    private SysDeviceService sysDeviceService;
    @Autowired
    public void setService(SysDeviceService sysDeviceService) {
        this.sysDeviceService = sysDeviceService;
    }

    @PostMapping("/addSysDevice")
    public R addSysDevice(@RequestBody SysDevice sysDevice){
        sysDeviceService.addSysDevice(sysDevice);
        return R.setOk();
    }
    @GetMapping("findById/{deviceId}")
    public R findById(@PathVariable String deviceId){
        SysDevice sysDevice = sysDeviceService.findById(deviceId);
        return R.setOk(sysDevice);
    }
}

